﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace FreeSwitch.EventSocket
{
	public static class StringHelper
	{
		public static string UpperCaseToCamelCase(this string value)
		{
			string result = string.Empty;
			for (int i = 0; i < value.Length - 1; i++)
			{
				if (value[i + 1] == '_')
				{
					result += char.ToUpper(value[i]);
					++i;
				}
				else
					result += char.ToLower(value[i]);
			}

			return result;
		}

		private static readonly DateTime UnixEpoch = new DateTime(1970, 01, 01);

		public static DateTime FromUnixTime(this string value)
		{
			int time;
			return int.TryParse(value, out time) ? UnixEpoch.AddSeconds(time) : DateTime.MinValue;
		}

	}
}
